//
//  SportStateController.swift
//  swiftProject
//
//  Created by ZhangSai on 2021/7/1.
//

import UIKit

class SportStateController: ZsBaseViewController {
    
    @IBOutlet weak var titleLab: UILabel!
    @IBOutlet weak var detailLab: UILabel!
    @IBOutlet weak var printBtn: UIButton!
    @IBOutlet weak var elseBtn: UIButton!
    
    var mailSn:String = ""
    var orderSn:String = ""

    override func viewDidLoad() {
        super.viewDidLoad()
        self.titleLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.spot_succeed)
        self.detailLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.order_submit_succeed)
        let roleType = WLUserModel.getRoleType()
        if roleType.contains(where: { (obj) -> Bool in
            if obj as! Int == 7 || obj as! Int == 3 {
                self.printBtn.isHidden = true
                return true
            } else {
                return false
            }
        }) {
            
        }
        elseBtn.setTitle(ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.order_again), for: .normal)
        self.backButtonItemInit()
    }
    
    func backButtonItemInit()  {
        let backBt = UIButton.init(type: .custom)
        backBt.frame = CGRect.init(x: 0, y: 0, width: 20, height: 20)
        backBt.setBackgroundImage(UIImage.init(named: "login_cancel"), for: .normal)
        backBt.addTarget(self, action: #selector(clickBackBarButton), for: .touchUpInside)
        let backItem = UIBarButtonItem.init(customView: backBt)
        self.navigationItem.setLeftBarButtonItems([backItem], animated: true)
    }
    @objc func clickBackBarButton()  {
        self.navigationController?.popViewController(animated: true)
    }
    
    @IBAction func clickActionBtn(_ sender: UIButton) {
        if sender.tag == 100 {
            let printSetCtrl:PrintController = PrintController.init()
            printSetCtrl.isShowPrint = true
            printSetCtrl.linkSucceedBlock = {
                Constants.window?.makeToastActivity(.center)
                let orderModel:OrderListModel = OrderListModel.init()
                orderModel.mailSn = self.mailSn
                orderModel.orderSn = self.orderSn
                //zs打印待处理
                
            }
            self.navigationController?.pushViewController(printSetCtrl, animated: true)
        } else if sender.tag == 101 {
            self.navigationController?.popViewController(animated: true)
        }
    }

}
